package com.kedeng.yangmuyi.service.impl;


import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kedeng.yangmuyi.dao.UserProfileDAO;
import com.kedeng.yangmuyi.dto.LoginUserDTO;
import com.kedeng.yangmuyi.dto.UserProfileDTO;
import com.kedeng.yangmuyi.model.ProfileDO;
import com.kedeng.yangmuyi.service.LoadUserDataService;

/**
 * 
 * load user profile by login email and login password.
 * 
 * @author: rqian
 * @version: 1.0, Apr 26, 2012
 */
@Service("loadUserDataService")
@Transactional
public class LoadUserDataServiceImpl implements LoadUserDataService {

	@Resource
	private UserProfileDAO userProfileDao;


	@Override
	public UserProfileDTO loadUserProfileWithLoginUserData(LoginUserDTO user) {
		String email = user.getEmail();
		String passwdMD5 = user.getPasswordWithMD5();

		ProfileDO profileDO = userProfileDao.queryUserProfileByLoginData(email, passwdMD5);
		if (profileDO == null) {
			return null;
		}
		UserProfileDTO profileDTO = new UserProfileDTO();
		BeanUtils.copyProperties(profileDO, profileDTO);
		return profileDTO;
	}

}
